package com.econ.powercloud.ems.controller;

import com.econ.powercloud.common.base.facade.pojo.MsgResult;
import com.econ.powercloud.ems.pojo.*;
import com.econ.powercloud.ems.service.biz.EmsAnalysisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author jwc
 * @since  2022/11/25
 */
@Api(tags = "全景分析")
@RestController
@RequestMapping("/api/v2/analysis")
@RequiredArgsConstructor
public class EmsAnalysisController extends ApiBaseController{
    private final EmsAnalysisService emsAnalysisService;

    @GetMapping("operationEvaluation")
    @ApiOperation("获取运行评价图的数据")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "energyStationId", value = "储能站id", dataType = "String")
    })
    public MsgResult<AnalysisTwoChartVO> operationEvaluation(@RequestParam("energyStationId") String energyStationId) {
        return successHandler(emsAnalysisService.getOperationEvaluation(energyStationId));
    }

    @GetMapping("analysisTableData")
    @ApiOperation("获取运行评价表格的数据")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "energyStationId", value = "储能站id", dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "time", value = "时间戳", dataType = "Long")
    })
    public MsgResult<List<AnalysisVO>> analysisTableData(@RequestParam(value = "energyStationId") String energyStationId,
                                                         @RequestParam(value = "time") Long time) {
        return successHandler(emsAnalysisService.getAnalysisTableData(energyStationId, time));
    }

    @GetMapping("electricity")
    @ApiOperation("获取电量指标(近30日)")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "energyStationId", value = "储能站id", dataType = "String")
    })
    public MsgResult<List<AnalysisVO>> electricity(@RequestParam(value = "energyStationId") String energyStationId) {
        return successHandler(emsAnalysisService.getElectricity(energyStationId));
    }

    @GetMapping("energyEfficiency")
    @ApiOperation("获取能效指标(近30日)")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "energyStationId", value = "储能站id", dataType = "String")
    })
    public MsgResult<List<AnalysisVO>> energyEfficiency(@RequestParam(value = "energyStationId") String energyStationId) {
        return successHandler(emsAnalysisService.getEnergyEfficiency(energyStationId));
    }

    @GetMapping("reliability")
    @ApiOperation("获取可靠性指标(近30日)")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "energyStationId", value = "储能站id", dataType = "String")
    })
    public MsgResult<List<AnalysisVO>> reliability(@RequestParam(value = "energyStationId") String energyStationId) {
        return successHandler(emsAnalysisService.getReliability(energyStationId));
    }
}
